package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.utils.Reservation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface ReservationMapper extends  BaseMapper<Reservation> {
    @Select("Select * From Reservation Where ReservationStatus IN ('未借出', '借出', '逾期') AND (ExpectedCheckoutStoreID=#{StoreID} OR ExpectedReturnStoreID=#{StoreID})")
    List<Reservation> getAllPossibleReservation(String storeID);

    @Update("UPDATE Reservation SET ReservationStatus = #{newReservationStatus}, RenewalPermission = #{RenewalPermission} WHERE ReservationID = #{reservationID}")
    void updateReservation(@Param("reservationID") String reservationID, @Param("newReservationStatus") String newReservationStatus, @Param("RenewalPermission") String RenewalPermission);

    @Select("Select * from reservation where userid=#{userId}")
    List<Reservation> getReservationByUserID(String UserID);

}
